<template>
  <div id="q-app">
    <a-config-provider :locale="locale">
      <router-view />
    </a-config-provider>
  </div>
</template>

<script>
import Vue from 'vue'
// 引入编辑器
// 核心样式
import './statics/font/iconfont.css'

import CommonConfig from 'src/assets/js/config'
import { enums, fromValue as $valueToEnum, getEnum as $getEnum } from 'src/assets/js/enums'
import * as utils from 'src/assets/js/util'
import filters from './filters/filter' // global filters
import Router from 'vue-router'
// 日期插件
import 'vue2-datepicker/index.css'
import 'src/css/datepicker.scss'
import 'vue2-datepicker/locale/zh-cn'
import DatePicker from 'vue2-datepicker'

import VueAwesomeSwiper from 'vue-awesome-swiper'
// require styles
import 'swiper/dist/css/swiper.css'
// 全局引入has指令用于判断按钮级别的权限
import has from 'src/directive/has' // waves directive
// 全局引入tabcur指令用于切换tab
import tabcur from 'src/directive/tabcur' // waves directive
// 全局引入stat指定用于埋点统计用户行为
import stat from 'src/directive/stat'
import 'src/directive/throttle'
import comInstall from './components/common/index'
import vMessage from './components/Message/index'
import statMixin from 'src/assets/js/stat-mixin'
import { bacBackSpace } from 'yz-help'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import VueClipboard from 'vue-clipboard2'
Vue.use(Antd)
Vue.use(vMessage)
Vue.use(comInstall)
import {
  saveFileForBlob,
  getUploadPath,
  showErrTips
} from 'src/assets/js/ali-oss-util'

Vue.directive('has', {
  inserted: has
})

Vue.directive('tabcur', {
  inserted: tabcur
})

Vue.directive('stat', {
  inserted: stat
})

Vue.use(VueAwesomeSwiper /* { default global options } */)
Vue.mixin(statMixin)
Vue.use(VueClipboard)

// 解决浮点数精度
import Big from 'big.js'
Vue.prototype.$Big = Big

Vue.prototype.$saveFileForBlob = saveFileForBlob
Vue.prototype.$getUploadPath = getUploadPath
Vue.prototype.$showErrTips = showErrTips

Vue.prototype.CommonConfig = CommonConfig
Vue.prototype.Enums = enums
// 枚举枚举值获取枚举对象
Vue.prototype.$valueToEnum = $valueToEnum
Vue.prototype.$getEnum = $getEnum
// 工具函数集
Vue.prototype.$utils = utils
Vue.component('date-picker', DatePicker)
// 使用 Event Bus
Vue.prototype.$bus = new Vue()
// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
// 解决路由由于版本原因报错
const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

export default {
  name: 'App',
  data () {
    return {
      locale: zhCN,
      updateLoading: false,
      isFirst: true
    }
  },
  mounted () {
    window.onkeydown = bacBackSpace
  }
}
</script>

<style>
</style>
